package c.c.a;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.Signature;
import java.security.MessageDigest;
import org.json.JSONObject;

public class n extends b2 {
    public final Context e;

    public n(Context context) {
        super(true, false);
        this.e = context;
    }

    public boolean b(JSONObject jSONObject) {
        PackageInfo packageInfo;
        Object obj = null;
        try {
            packageInfo = this.e.getPackageManager().getPackageInfo(this.e.getPackageName(), 64);
        } catch (Throwable th) {
            m0.b(th);
            packageInfo = null;
        }
        if (packageInfo != null) {
            Signature[] signatureArr = packageInfo.signatures;
            if (signatureArr != null && signatureArr.length > 0) {
                Signature signature = signatureArr[0];
                if (signature != null) {
                    byte[] toByteArray = signature.toByteArray();
                    if (toByteArray != null) {
                        try {
                            if (toByteArray.length != 0) {
                                MessageDigest instance = MessageDigest.getInstance("MD5");
                                instance.update(toByteArray);
                                obj = k0.a(instance.digest());
                            }
                        } catch (Exception unused) {
                        }
                    }
                }
            }
        }
        if (obj != null) {
            jSONObject.put("sig_hash", obj);
        }
        return true;
    }
}
